package demo3;

//牛客网:DNA序列
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int n = str.length();
        int l = in.nextInt();

        String ret = "";
        double k = -1;
        int count = 0;
        for(int i = 0, j = 0; i<n; i++) {
            if(str.charAt(i) == 'C' || str.charAt(i) == 'G') {
                count++;
            }

            while(i-j>=l) {
                if(str.charAt(j) == 'C' || str.charAt(j) == 'G') {
                    count--;
                }
                j++;
                if((count*1.0)/(i-j+1) > k) {
                    ret = str.substring(j,i+1);
                    k = (count*1.0)/(i-j+1);
                }
            }

            if(i-j+1>=l && (count*1.0)/(i-j+1) > k) {
                ret = str.substring(j,i+1);
                k = (count*1.0)/(i-j+1);
            }
        }

        System.out.println(ret);
    }
}

/*

AACTGTGCACGACCTGA
5

 */